<template>
  <div class="about-master-container">
    <base-breadcrumb>
      <searchData :search-data="searchArr" @search="search" />
      <a-card :bordered="false">
        <!-- <title-name>工期风险</title-name> -->
        <list-table
          ref="table"
          :columns="columns"
          :request="loadData"
          :exportPermission="{ select: 'lcm_013_exp_03', all: 'lcm_013_exp_03' }"
          :exportConfig="{use:true, select: '工期风险',all: '工期风险'}"
        >
          <span slot="index" slot-scope="text, record, index">{{ index + 1 }}</span>
          <template slot="operation" slot-scope="text, record">
            <MoreButton>
              <a
                v-btn-permission="'lcm_013_loo_01'"
               @click="lookItemHandler(record)"
              >查看</a>
              <a   v-btn-permission="'lcm_013_zhh_02'" v-if="record.isChangeStr === '未转化'" @click="transfer(record)">转化为风险</a>
            </MoreButton>
          </template>
          <template slot="checkStatusStr" slot-scope="text, record"> 
            {{record.checkStatusStr?record.checkStatusStr:'-'}}
          </template>
           <template slot="selfCheckTime" slot-scope="text, record"> 
            {{record.selfCheckTime?record.selfCheckTime.slice(0,10):''}}
          </template>
        </list-table>
      </a-card>
    </base-breadcrumb>
  </div>
</template>

<script>
import SelectSubCompany from '@/components/Select/SelectSubCompany'
import SelectProject from '@/components/Select/SelectProject'
import OrgTreeSelect from '@/components/OrgTreeSelect'
import { findListByMain } from '@/api/legal/risk/periodRisk'

export default {
  name: 'periodRisk'+Date.now(),
  data() {
    return {
      columns: [
        { title: '序号', dataIndex: 'index', width: 70, scopedSlots: { customRender: 'index' } },
        { title: '分公司', dataIndex: 'branchName', width: 170,ellipsis: true,},
        { title: '项目名称', dataIndex: 'projectName', width: 220,ellipsis: true,},
        { title: '预警级别', dataIndex: 'warnLevelName', width: 100,ellipsis: true,},
        { title: '检查人', dataIndex: 'creatorName', width: 220,ellipsis: true,},
        { title: '检查时间', dataIndex: 'selfCheckTime', width: 270,ellipsis: true,scopedSlots: { customRender: 'selfCheckTime' }},
        { title: '拟采取措施', dataIndex: 'measureStatusStr', width: 270,ellipsis: true,},
        { title: '验收记录', dataIndex: 'checkStatusStr', width: 200,ellipsis: true,scopedSlots: { customRender: 'checkStatusStr' }},
        { title: '状态', dataIndex: 'isChangeStr', width: 100 },
        {title: '操作',width: 150,fixed: 'right',scopedSlots: { customRender: 'operation' }}
      ],
      searchArr: [
        { name: '所属单位', valueKey: 'searchQuery', type: OrgTreeSelect, },
        // {name: '分公司',valueKey: 'branchId',type: SelectSubCompany,
                // isDefaultSelected:true,isHeadOffice:true},
        // {name: '项目名称',type: SelectProject,valueKey: 'projectId',keyValue: 'branchId',isDefaultSelected:true,autoSelected:true,isSelf:false},
        {name: '预警级别',type: 'select',value: 'warnLevel',
          data: [{ label: '蓝色', value: 0 },{ label: '黄色', value: 1 },{label:'红色',value:2}]
        },
        {name: '状态',type: 'select',value: 'isChange',
          data: [{ label: '未转化', value: 0 },{ label: '已转化', value: 1 }]
        }
      ],
      loadData: (parameter) => {
              let that = this
              parameter.pageNum = parameter.pageNo;
              delete parameter.pageNo;
              const requestParameters = Object.assign({}, parameter, { param: that.queryParam })
              return findListByMain(requestParameters).then((res) => {
                 return {
                   code: 200,
                   ...res.data,
                   data: res.data.list,
                   currentPage:res.data.pageNum,
                   totalSize:res.data.total,
                   totalPage:res.data.firstPage
                 }
              })
            },
       queryParam: {}, // 搜索参数集
    }
  },
  computed: {
    
  },
  methods: {
    search(val = {}) {
      this.queryParam = val
      this.$refs.table.refresh()
    },
    transfer(row) {
      let hideLossId = row.id
      delete row.id
      // row.confirmationRight = row.confirmationRight || ''
      // row.projectActOutPutValueSoFar = row.projectActOutPutValueSoFar || ''
      // row.projectActCostSoFar = row.projectActCostSoFar || ''
      // row.confirmationRate = row.confirmationRate || ''
      this.$nav('/legal/risk/list/add',
        {
          ...row,
          hideLossId,
          isPeriodRisk:true
        })
    },
     // 查看
    lookItemHandler(record) {
      this.$router.push({
        path: '/project/look',
        query: {
          _id: record.id
        }
      })
    }
  }
}
</script>
